import req from '@/utils/request';
import * as URL from '@/constants/api';

// 获取文章新闻推荐
export function getNewsList(id) {
  return req({
    url: URL.NEWS_LIST,
    params: {
      channel_id: id,
      timestamp: Date.now(),
    }
  })
    .then(res => res.data?.data.results);
}
// 获取所有频道列表
export function getAllChannelList() {
  return req({
    url: URL.ALL_CHANNEL_LIST,
  })
    .then(res => res.data?.data.channels);
}
// 获取用户频道列表
export function getChannelList() {
  return req({
    url: URL.CHANNEL_LIST,
  })
    .then(res => res.data?.data.channels);
}
export function setChannelList(data) {
  return req({
    url: URL.CHANNEL_LIST,
    method: 'PUT',
    data: {
      channels: data,
    }
  })
}